<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>节流</title>
</head>
<body>
  <button class="btn">按钮</button>
  <div></div>
  <div></div>
  <div></div>
  <script>

    function roel(callback, wait=2000) {
      let timeOut
      return function (...args) {
        if(!timeOut) {
          timeOut = setTimeout(() => {
            callback(args)
            timeOut = null
          }, wait)
        }
      }
    } 
    let newFn = roel (() => {
      console.log('点击了')
    },2000)
    let btn = document.querySelector('.btn')
    btn.addEventListener('click', () => {
      newFn()
    })

    let divs = document.getElementsByTagName('div')
    console.log(divs)
    // 转换为数组
    let divArr = Array.prototype.slice.call(divs)
    console.log(divArr)

    
  </script>
</body>
</html>